# Maintainer: Bruno Pagani (a.k.a. ArchangeGabriel) <archange@archlinux.org>
# Contributor: Mirco Tischler <mt-ml at gmx dot de>

pkgname=fwupd
pkgver=dummy
pkgrel=1
pkgdesc='A system daemon to allow session software to update firmware'
arch=('i686' 'x86_64')
url='https://github.com/fwupd/fwupd'
license=('GPL2')
depends=('libgusb' 'modemmanager' 'tpm2-tss')
makedepends=('meson' 'valgrind' 'gobject-introspection' 'gi-docgen' 'git'
             'python-cairo' 'noto-fonts' 'noto-fonts-cjk' 'python-gobject' 'vala'
             'libdrm' 'curl' 'polkit' 'xz')

pkgver() {
    cd ${pkgname}

    VERSION=$(git describe | sed 's/-/.r/;s/-/./')
    [ -z $VERSION ] && VERSION=$(head meson.build | grep ' version:' | cut -d \' -f2)

    echo $VERSION
}

build() {
    cd ${pkgname}
    if [ -n "$CI" ]; then
        export CI="--wrap-mode=default"
    fi
    arch-meson -D b_lto=false $CI ../build \
        -Dplugin_intel_spi=true \
        -Dplugin_powerd=disabled \
        -Dlaunchd=disabled \
        -Ddocs=enabled \
        -Defi_binary=false \
        -Dsupported_build=enabled

    ninja -v -C ../build
}

check() {
    CACHE_DIRECTORY=/tmp ninja -C build test
}

package() {
    DESTDIR="${pkgdir}" ninja -C build install
}
